package com.wfyvv.resteasy.common.util;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("Duplicates")
public class ResultUtils {

    private static int SUCCESS = 1;
    private static int ERROR = 0;

    private static String CODE = "code";
    private static String DATA = "data";
    private static String MSG = "msg";

    public static Map<String,Object> success(Object data, String msg){
        Map<String,Object> map = new HashMap<>();
        map.put(CODE, SUCCESS);
        map.put(DATA, data);
        map.put(MSG, msg);
        return map;
    }

    public static Map<String,Object> success(Object data){
        Map<String,Object> map = new HashMap<>();
        map.put(CODE, SUCCESS);
        map.put(DATA, data);
        return map;
    }

    public static Map<String,Object> error(Object data, String msg){
        Map<String,Object> map = new HashMap<>();
        map.put(CODE, ERROR);
        map.put(DATA, data);
        map.put(MSG, msg);
        return map;
    }

    public static Map<String,Object> error(String msg){
        Map<String,Object> map = new HashMap<>();
        map.put(CODE, ERROR);
        map.put(MSG, msg);
        return map;
    }

}
